package longcaisuyun.longcai.com.utils;

import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import android.widget.Toast;

import net.tsz.afinal.FinalHttp;
import net.tsz.afinal.http.AjaxCallBack;

import longcaisuyun.longcai.com.myview.CustomProgressDialog;

/**
 * Created by Administrator on 2016/3/31.
 */
public class MyViewUtil {
    public CustomProgressDialog progressDialog = null;

    public void startProgressDialog(final Context context, final FinalHttp finalHttp, final String string) {
        if (progressDialog == null) {
            progressDialog = CustomProgressDialog
                    .createDialog(context);
            progressDialog.setCancelable(true);
        }
        progressDialog.show();
        progressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                finalHttp.delete(string, new AjaxCallBack<String>() {
                });
            }
        });
    }
    public void stopProgressDialog() {
        if (progressDialog != null) {
            progressDialog.dismiss();
            progressDialog = null;
        }
    }
    public void startProgressDialog(final Context context) {
        if (progressDialog == null) {
            progressDialog = CustomProgressDialog.createDialog(context);
            progressDialog.setCancelable(false);
        }
        progressDialog.show();
    }
}
